package com.lecture.springlecture.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2021/7/28 20:37
 */
@RestController
@RequestMapping("redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("getRedis")
    public String getRedis(String key) {
        redisTemplate.opsForValue().set(key, "插入一句话");
        Object o = redisTemplate.opsForValue().get(key);
        return o.toString();
    }
}

